import Vue from 'vue'
import Vuex from 'vuex'
import {
	cloneDeep
} from 'lodash'
Vue.use(Vuex)

export default new Vuex.Store({
	state: {
		userInfo: {
			avatar: require('@/assets/img/avatar.gif'),
			name: '超级管理员',
			username: 'admin',
			role: '管理员'
		},
		logo: {
			title: '河南巨阔网络科技',
			img: require('@/assets/img/logo.png'),
			color: '#fff',
			bgcolor: '#2b2f3a',
		},
		menu: {
			color: '#bfcbd9',
			bgcolor: '#304156',
			collapse: false,
			activeName: '/home',
			tabs: [],
			list: [],
		},
		size: sessionStorage.getItem('ElementSize') || 'mini'

	},
	getters: {},
	mutations: {
		updateMenu(state, {
			key,
			val
		}) {
			Vue.prototype.$set(state.menu, key, val)
			// console.log(state.menu, key, val)
		},
		resetStore(state) {
			Object.keys(state).forEach((key) => {
				if (window.SITE_CONFIG['storeState']) {
					state[key] = cloneDeep(window.SITE_CONFIG['storeState'][key])
				}
			})
		},
		setSize(state, size) {
			state.size = size
			sessionStorage.setItem('ElementSize', size)
		}
	},
	actions: {
		setSize({
			commit
		}, size) {
			commit('setSize', size)
		}
	},
	modules: {}
})